package com.punai.system.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.punai.common.exception.ServiceException;
import com.punai.common.utils.DateUtils;
import com.punai.system.bo.LoginUserRes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.punai.system.mapper.SysWechatcomloginLogMapper;
import com.punai.system.domain.SysWechatcomloginLog;
import com.punai.system.service.ISysWechatcomloginLogService;

/**
 * 工具企业微信登录日志Service业务层处理
 *
 * @author zxw_
 * @date 2023-04-23
 */
@Service
public class SysWechatcomloginLogServiceImpl extends ServiceImpl<SysWechatcomloginLogMapper,SysWechatcomloginLog> implements ISysWechatcomloginLogService
{
    @Autowired
    private SysWechatcomloginLogMapper sysWechatcomloginLogMapper;

    @Override
    public LoginUserRes findRuleByState(String state) {

        SysWechatcomloginLog sysWechatcomloginLog = sysWechatcomloginLogMapper.selectOne(
                Wrappers.<SysWechatcomloginLog>lambdaQuery()
                        .eq(SysWechatcomloginLog::getState, state)
        );
        if(sysWechatcomloginLog==null) {
            throw new ServiceException("未登录成功，请联系管理员查明原因");
        }
        return sysWechatcomloginLog.getLoginUserResObj();
    }
}
